def a(s):
    list = []
    slovar = {")":"(", "]":"[", "}":"{", ">":"<"}
    for i in s:
        if i in slovar.values():
            list.append(i)
        elif i in slovar:
            if not list or slovar[i] != list.pop():
                return False
    return True

s = input()

print(a(s))